#include <highgui.h>
#include <iostream>
#include <stdlib.h>

int main( int argc, char** argv ) {
	cvNamedWindow( "Example Camera Display", CV_WINDOW_AUTOSIZE );
	
	int camNum = 0;
	
	if (argc > 1) {
		camNum = atoi(argv[1]);
	}
	
	
	CvCapture* capture = cvCreateCameraCapture(camNum);
	IplImage* frame;
	while(1) {
		frame = cvQueryFrame( capture );
		if( !frame ) break;
		cvShowImage( "Example Camera Display", frame );
		char c = cvWaitKey(33);
		if( c == 27 ) break;
	}
	cvReleaseCapture( &capture );
	cvDestroyWindow( "Example Camera Display" );
}